
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 02/09/2014 22:44:37
-- Generated from EDMX file: E:\Chauit\Project\OtherProject\QuanLyThongTinCoSo\QuanLyThongTinCoSo\DatabaseModel\Model\QLTTCS_DbModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [QLTTCS];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_PhieuDieuTraCoSo_CanBoQuanLy]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PhieuDieuTraCoSo] DROP CONSTRAINT [FK_PhieuDieuTraCoSo_CanBoQuanLy];
GO
IF OBJECT_ID(N'[dbo].[FK_PhieuDieuTraCoSo_CapQuanLyHanhChinh]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PhieuDieuTraCoSo] DROP CONSTRAINT [FK_PhieuDieuTraCoSo_CapQuanLyHanhChinh];
GO
IF OBJECT_ID(N'[dbo].[FK_PhieuDieuTraCoSo_CoQuanQuanLyPCCC]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PhieuDieuTraCoSo] DROP CONSTRAINT [FK_PhieuDieuTraCoSo_CoQuanQuanLyPCCC];
GO
IF OBJECT_ID(N'[dbo].[FK_PhieuDieuTraCoSo_Doi]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PhieuDieuTraCoSo] DROP CONSTRAINT [FK_PhieuDieuTraCoSo_Doi];
GO
IF OBJECT_ID(N'[dbo].[FK_PhieuDieuTraCoSo_HinhThucDauTu]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PhieuDieuTraCoSo] DROP CONSTRAINT [FK_PhieuDieuTraCoSo_HinhThucDauTu];
GO
IF OBJECT_ID(N'[dbo].[FK_PhieuDieuTraCoSo_Phong]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PhieuDieuTraCoSo] DROP CONSTRAINT [FK_PhieuDieuTraCoSo_Phong];
GO
IF OBJECT_ID(N'[dbo].[FK_PhieuDieuTraCoSo_So]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PhieuDieuTraCoSo] DROP CONSTRAINT [FK_PhieuDieuTraCoSo_So];
GO
IF OBJECT_ID(N'[dbo].[FK_PhieuDieuTraCoSo_ThanhPhanKinhTe]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PhieuDieuTraCoSo] DROP CONSTRAINT [FK_PhieuDieuTraCoSo_ThanhPhanKinhTe];
GO
IF OBJECT_ID(N'[dbo].[FK_PhuongTien_LoaiPhuongTien]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PhuongTien] DROP CONSTRAINT [FK_PhuongTien_LoaiPhuongTien];
GO
IF OBJECT_ID(N'[dbo].[FK_UserRole_Role]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[UserRole] DROP CONSTRAINT [FK_UserRole_Role];
GO
IF OBJECT_ID(N'[dbo].[FK_UserRole_User]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[UserRole] DROP CONSTRAINT [FK_UserRole_User];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[CanBoQuanLy]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CanBoQuanLy];
GO
IF OBJECT_ID(N'[dbo].[CapQuanLyHanhChinh]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CapQuanLyHanhChinh];
GO
IF OBJECT_ID(N'[dbo].[CoQuanQuanLyPCCC]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CoQuanQuanLyPCCC];
GO
IF OBJECT_ID(N'[dbo].[Doi]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Doi];
GO
IF OBJECT_ID(N'[dbo].[HinhThucDauTu]', 'U') IS NOT NULL
    DROP TABLE [dbo].[HinhThucDauTu];
GO
IF OBJECT_ID(N'[dbo].[LoaiPhuongTien]', 'U') IS NOT NULL
    DROP TABLE [dbo].[LoaiPhuongTien];
GO
IF OBJECT_ID(N'[dbo].[NganhLinhVuc]', 'U') IS NOT NULL
    DROP TABLE [dbo].[NganhLinhVuc];
GO
IF OBJECT_ID(N'[dbo].[PhieuDieuTraCoSo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PhieuDieuTraCoSo];
GO
IF OBJECT_ID(N'[dbo].[Phong]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Phong];
GO
IF OBJECT_ID(N'[dbo].[PhuongTien]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PhuongTien];
GO
IF OBJECT_ID(N'[dbo].[Role]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Role];
GO
IF OBJECT_ID(N'[dbo].[So]', 'U') IS NOT NULL
    DROP TABLE [dbo].[So];
GO
IF OBJECT_ID(N'[dbo].[ThanhPhanKinhTe]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ThanhPhanKinhTe];
GO
IF OBJECT_ID(N'[dbo].[User]', 'U') IS NOT NULL
    DROP TABLE [dbo].[User];
GO
IF OBJECT_ID(N'[dbo].[UserRole]', 'U') IS NOT NULL
    DROP TABLE [dbo].[UserRole];
GO
IF OBJECT_ID(N'[dbo].[VanBanThamDuyet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[VanBanThamDuyet];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'CanBoQuanLies'
CREATE TABLE [dbo].[CanBoQuanLies] (
    [ID] uniqueidentifier  NOT NULL,
    [MaCanBo] nvarchar(50)  NOT NULL,
    [TenCanBo] nvarchar(255)  NOT NULL
);
GO

-- Creating table 'CapQuanLyHanhChinhs'
CREATE TABLE [dbo].[CapQuanLyHanhChinhs] (
    [ID] uniqueidentifier  NOT NULL,
    [Ma] nvarchar(50)  NOT NULL,
    [Ten] nvarchar(255)  NOT NULL,
    [DienGiai] nvarchar(max)  NULL
);
GO

-- Creating table 'CoQuanQuanLyPCCCs'
CREATE TABLE [dbo].[CoQuanQuanLyPCCCs] (
    [ID] uniqueidentifier  NOT NULL,
    [MaCoQuan] nvarchar(50)  NOT NULL,
    [TenCoQuan] nvarchar(255)  NOT NULL,
    [DienGiai] nvarchar(max)  NULL
);
GO

-- Creating table 'Dois'
CREATE TABLE [dbo].[Dois] (
    [ID] uniqueidentifier  NOT NULL,
    [MaDoi] nchar(10)  NULL,
    [TenDoi] nchar(10)  NULL
);
GO

-- Creating table 'HinhThucDauTus'
CREATE TABLE [dbo].[HinhThucDauTus] (
    [ID] uniqueidentifier  NOT NULL,
    [Ma] nvarchar(50)  NOT NULL,
    [Ten] nvarchar(255)  NOT NULL,
    [DienGiai] nvarchar(max)  NULL
);
GO

-- Creating table 'LoaiPhuongTiens'
CREATE TABLE [dbo].[LoaiPhuongTiens] (
    [ID] uniqueidentifier  NOT NULL,
    [MaLoaiPhuongTien] nvarchar(50)  NOT NULL,
    [TenLoaiPhuongTien] nvarchar(255)  NOT NULL,
    [DienGiai] nvarchar(4000)  NULL
);
GO

-- Creating table 'NganhLinhVucs'
CREATE TABLE [dbo].[NganhLinhVucs] (
    [ID] uniqueidentifier  NOT NULL,
    [MaNganhLinhVuc] nvarchar(50)  NULL,
    [TenNganhLinhVuc] nvarchar(255)  NULL,
    [DienGiai] nvarchar(4000)  NULL
);
GO

-- Creating table 'PhieuDieuTraCoSoes'
CREATE TABLE [dbo].[PhieuDieuTraCoSoes] (
    [ID] uniqueidentifier  NOT NULL,
    [TenCoSo] nvarchar(255)  NULL,
    [Email] nvarchar(50)  NULL,
    [Website] nvarchar(50)  NULL,
    [NamThanhLap] nvarchar(50)  NULL,
    [DiaChi_So] nvarchar(50)  NULL,
    [DiaChi_Duong] nvarchar(255)  NULL,
    [DiaChi_PhuongOrXa] nvarchar(255)  NULL,
    [DiaChi_QuanOrHuyen] nvarchar(255)  NULL,
    [KhuOrCumCongNghiep] nvarchar(50)  NULL,
    [NguoiDungDauCoSo] nvarchar(50)  NULL,
    [DienThoai] nvarchar(50)  NULL,
    [CoQuanQuanLyID] uniqueidentifier  NULL,
    [NgayLapPhieu] datetime  NULL,
    [CanBoQuanLyID] uniqueidentifier  NULL,
    [SoID] uniqueidentifier  NULL,
    [PhongID] uniqueidentifier  NULL,
    [DoiID] uniqueidentifier  NULL,
    [CapQuanLyHanhChinhID] uniqueidentifier  NULL,
    [HinhThucDauTuID] uniqueidentifier  NULL,
    [ThanhPhanKinhTeID] uniqueidentifier  NULL
);
GO

-- Creating table 'Phongs'
CREATE TABLE [dbo].[Phongs] (
    [ID] uniqueidentifier  NOT NULL,
    [MaPhong] nvarchar(50)  NOT NULL,
    [TenPhong] nvarchar(255)  NOT NULL
);
GO

-- Creating table 'PhuongTiens'
CREATE TABLE [dbo].[PhuongTiens] (
    [ID] uniqueidentifier  NOT NULL,
    [MaPhuongTien] nvarchar(50)  NOT NULL,
    [TenPhuongTien] nvarchar(255)  NOT NULL,
    [DienGiai] nvarchar(4000)  NULL,
    [LoaiPhuongTienID] uniqueidentifier  NULL,
    [PhanLoaiChiTiet] nvarchar(1000)  NULL,
    [SoLuong] float  NULL,
    [TinhTrangHoatDong] nvarchar(50)  NULL,
    [ViTriLapDat] nvarchar(1000)  NULL
);
GO


-- Creating table 'Soes'
CREATE TABLE [dbo].[Soes] (
    [ID] uniqueidentifier  NOT NULL,
    [MaSo] nvarchar(50)  NOT NULL,
    [TenSo] nvarchar(255)  NOT NULL,
    [DienGiai] nvarchar(max)  NULL
);
GO



-- Creating table 'VanBanThamDuyets'
CREATE TABLE [dbo].[VanBanThamDuyets] (
    [ID] uniqueidentifier  NOT NULL,
    [TenVanBan] nvarchar(255)  NOT NULL,
    [SoVanBan] nvarchar(50)  NOT NULL,
    [NgayCap] datetime  NULL,
    [CoQuanCap] nvarchar(255)  NULL,
    [GhiChu] nvarchar(4000)  NULL
);
GO

-- Creating table 'ThanhPhanKinhTes'
CREATE TABLE [dbo].[ThanhPhanKinhTes] (
    [ID] uniqueidentifier  NOT NULL,
    [Ma] nvarchar(50)  NOT NULL,
    [Ten] nvarchar(255)  NOT NULL,
    [DienGiai] nvarchar(max)  NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [ID] in table 'CanBoQuanLies'
ALTER TABLE [dbo].[CanBoQuanLies]
ADD CONSTRAINT [PK_CanBoQuanLies]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'CapQuanLyHanhChinhs'
ALTER TABLE [dbo].[CapQuanLyHanhChinhs]
ADD CONSTRAINT [PK_CapQuanLyHanhChinhs]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'CoQuanQuanLyPCCCs'
ALTER TABLE [dbo].[CoQuanQuanLyPCCCs]
ADD CONSTRAINT [PK_CoQuanQuanLyPCCCs]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Dois'
ALTER TABLE [dbo].[Dois]
ADD CONSTRAINT [PK_Dois]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'HinhThucDauTus'
ALTER TABLE [dbo].[HinhThucDauTus]
ADD CONSTRAINT [PK_HinhThucDauTus]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'LoaiPhuongTiens'
ALTER TABLE [dbo].[LoaiPhuongTiens]
ADD CONSTRAINT [PK_LoaiPhuongTiens]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'NganhLinhVucs'
ALTER TABLE [dbo].[NganhLinhVucs]
ADD CONSTRAINT [PK_NganhLinhVucs]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'PhieuDieuTraCoSoes'
ALTER TABLE [dbo].[PhieuDieuTraCoSoes]
ADD CONSTRAINT [PK_PhieuDieuTraCoSoes]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Phongs'
ALTER TABLE [dbo].[Phongs]
ADD CONSTRAINT [PK_Phongs]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'PhuongTiens'
ALTER TABLE [dbo].[PhuongTiens]
ADD CONSTRAINT [PK_PhuongTiens]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Soes'
ALTER TABLE [dbo].[Soes]
ADD CONSTRAINT [PK_Soes]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO


-- Creating primary key on [ID] in table 'VanBanThamDuyets'
ALTER TABLE [dbo].[VanBanThamDuyets]
ADD CONSTRAINT [PK_VanBanThamDuyets]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'ThanhPhanKinhTes'
ALTER TABLE [dbo].[ThanhPhanKinhTes]
ADD CONSTRAINT [PK_ThanhPhanKinhTes]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [CanBoQuanLyID] in table 'PhieuDieuTraCoSoes'
ALTER TABLE [dbo].[PhieuDieuTraCoSoes]
ADD CONSTRAINT [FK_PhieuDieuTraCoSo_CanBoQuanLy]
    FOREIGN KEY ([CanBoQuanLyID])
    REFERENCES [dbo].[CanBoQuanLies]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PhieuDieuTraCoSo_CanBoQuanLy'
CREATE INDEX [IX_FK_PhieuDieuTraCoSo_CanBoQuanLy]
ON [dbo].[PhieuDieuTraCoSoes]
    ([CanBoQuanLyID]);
GO

-- Creating foreign key on [CapQuanLyHanhChinhID] in table 'PhieuDieuTraCoSoes'
ALTER TABLE [dbo].[PhieuDieuTraCoSoes]
ADD CONSTRAINT [FK_PhieuDieuTraCoSo_CapQuanLyHanhChinh]
    FOREIGN KEY ([CapQuanLyHanhChinhID])
    REFERENCES [dbo].[CapQuanLyHanhChinhs]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PhieuDieuTraCoSo_CapQuanLyHanhChinh'
CREATE INDEX [IX_FK_PhieuDieuTraCoSo_CapQuanLyHanhChinh]
ON [dbo].[PhieuDieuTraCoSoes]
    ([CapQuanLyHanhChinhID]);
GO

-- Creating foreign key on [CoQuanQuanLyID] in table 'PhieuDieuTraCoSoes'
ALTER TABLE [dbo].[PhieuDieuTraCoSoes]
ADD CONSTRAINT [FK_PhieuDieuTraCoSo_CoQuanQuanLyPCCC]
    FOREIGN KEY ([CoQuanQuanLyID])
    REFERENCES [dbo].[CoQuanQuanLyPCCCs]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PhieuDieuTraCoSo_CoQuanQuanLyPCCC'
CREATE INDEX [IX_FK_PhieuDieuTraCoSo_CoQuanQuanLyPCCC]
ON [dbo].[PhieuDieuTraCoSoes]
    ([CoQuanQuanLyID]);
GO

-- Creating foreign key on [DoiID] in table 'PhieuDieuTraCoSoes'
ALTER TABLE [dbo].[PhieuDieuTraCoSoes]
ADD CONSTRAINT [FK_PhieuDieuTraCoSo_Doi]
    FOREIGN KEY ([DoiID])
    REFERENCES [dbo].[Dois]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PhieuDieuTraCoSo_Doi'
CREATE INDEX [IX_FK_PhieuDieuTraCoSo_Doi]
ON [dbo].[PhieuDieuTraCoSoes]
    ([DoiID]);
GO

-- Creating foreign key on [HinhThucDauTuID] in table 'PhieuDieuTraCoSoes'
ALTER TABLE [dbo].[PhieuDieuTraCoSoes]
ADD CONSTRAINT [FK_PhieuDieuTraCoSo_HinhThucDauTu]
    FOREIGN KEY ([HinhThucDauTuID])
    REFERENCES [dbo].[HinhThucDauTus]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PhieuDieuTraCoSo_HinhThucDauTu'
CREATE INDEX [IX_FK_PhieuDieuTraCoSo_HinhThucDauTu]
ON [dbo].[PhieuDieuTraCoSoes]
    ([HinhThucDauTuID]);
GO

-- Creating foreign key on [LoaiPhuongTienID] in table 'PhuongTiens'
ALTER TABLE [dbo].[PhuongTiens]
ADD CONSTRAINT [FK_PhuongTien_LoaiPhuongTien]
    FOREIGN KEY ([LoaiPhuongTienID])
    REFERENCES [dbo].[LoaiPhuongTiens]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PhuongTien_LoaiPhuongTien'
CREATE INDEX [IX_FK_PhuongTien_LoaiPhuongTien]
ON [dbo].[PhuongTiens]
    ([LoaiPhuongTienID]);
GO

-- Creating foreign key on [PhongID] in table 'PhieuDieuTraCoSoes'
ALTER TABLE [dbo].[PhieuDieuTraCoSoes]
ADD CONSTRAINT [FK_PhieuDieuTraCoSo_Phong]
    FOREIGN KEY ([PhongID])
    REFERENCES [dbo].[Phongs]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PhieuDieuTraCoSo_Phong'
CREATE INDEX [IX_FK_PhieuDieuTraCoSo_Phong]
ON [dbo].[PhieuDieuTraCoSoes]
    ([PhongID]);
GO

-- Creating foreign key on [SoID] in table 'PhieuDieuTraCoSoes'
ALTER TABLE [dbo].[PhieuDieuTraCoSoes]
ADD CONSTRAINT [FK_PhieuDieuTraCoSo_So]
    FOREIGN KEY ([SoID])
    REFERENCES [dbo].[Soes]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PhieuDieuTraCoSo_So'
CREATE INDEX [IX_FK_PhieuDieuTraCoSo_So]
ON [dbo].[PhieuDieuTraCoSoes]
    ([SoID]);
GO

-- Creating foreign key on [ThanhPhanKinhTeID] in table 'PhieuDieuTraCoSoes'
ALTER TABLE [dbo].[PhieuDieuTraCoSoes]
ADD CONSTRAINT [FK_PhieuDieuTraCoSo_ThanhPhanKinhTe]
    FOREIGN KEY ([ThanhPhanKinhTeID])
    REFERENCES [dbo].[ThanhPhanKinhTes]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PhieuDieuTraCoSo_ThanhPhanKinhTe'
CREATE INDEX [IX_FK_PhieuDieuTraCoSo_ThanhPhanKinhTe]
ON [dbo].[PhieuDieuTraCoSoes]
    ([ThanhPhanKinhTeID]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------

GO
/****** Object:  Table [dbo].[User]    Script Date: 02/09/2014 22:53:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[User](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Username] [varchar](255) NOT NULL,
	[Password] [varchar](255) NOT NULL,
	[FullName] [nvarchar](255) NULL,
 CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Role]    Script Date: 02/09/2014 22:53:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Role](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[RoleName] [nvarchar](255) NOT NULL,
 CONSTRAINT [PK_Role] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[UserRole]    Script Date: 02/09/2014 22:53:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[UserRole](
	[UserId] [int] NOT NULL,
	[RoleId] [int] NOT NULL,
 CONSTRAINT [PK_UserRole] PRIMARY KEY CLUSTERED 
(
	[UserId] ASC,
	[RoleId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  ForeignKey [FK_UserRole_Role]    Script Date: 02/09/2014 22:53:59 ******/
ALTER TABLE [dbo].[UserRole]  WITH CHECK ADD  CONSTRAINT [FK_UserRole_Role] FOREIGN KEY([RoleId])
REFERENCES [dbo].[Role] ([Id])
GO
ALTER TABLE [dbo].[UserRole] CHECK CONSTRAINT [FK_UserRole_Role]
GO
/****** Object:  ForeignKey [FK_UserRole_User]    Script Date: 02/09/2014 22:53:59 ******/
ALTER TABLE [dbo].[UserRole]  WITH CHECK ADD  CONSTRAINT [FK_UserRole_User] FOREIGN KEY([UserId])
REFERENCES [dbo].[User] ([Id])
GO
ALTER TABLE [dbo].[UserRole] CHECK CONSTRAINT [FK_UserRole_User]
GO
